package app.models;

import java.util.List;
import org.javalite.activejdbc.Model;
import org.javalite.activejdbc.annotations.IdName;
import org.javalite.activejdbc.annotations.Table;

/**
 *
 * @author Kseniya Artsiukhova <kartsiukhova@productiveedge.com>
 */
@Table("genres")
@IdName("genre_id")
public class Genre extends Model {

    public void setGenreId(Long genreId) {
        setLong("genre_id", genreId);
    }

    public Long getGenreId() {
        return getLong("genre_id");
    }

    public void setGenreName(String genre) {
        setString("genre", genre);
    }

    public String getGenreName() {
        return getString("genre");
    }

    public void setPublicationsTypeId(Long publucationsTypeId) {
        setLong("publication_type_id", publucationsTypeId);
    }

    public Long getPublicationsTypeId() {
        return getLong("publication_type_id");
    }

    public static Genre getGenreByCode(String genreCode) {
        return findFirst("genre = ?", genreCode);
    }

    public List<Book> getBookList() {
        return getAll(Book.class);
    }

    public List<PublicationType> getPublicationTypeList() {
        return getAll(PublicationType.class);
    }
}
